#include "cardpanel.h"

CardPanel::CardPanel(QWidget *parent) : QWidget(parent)
{
    this->m_isfront=true;
}

void CardPanel::setImage(QPixmap &front, QPixmap &back)
{
    this->m_front=front;
    this->m_back=back;

    setFixedSize(m_front.size());
    update();//手动更新
}

QPixmap CardPanel::getImage()
{
    return this->m_front;

}

void CardPanel::paintEvent(QPaintEvent *event)
{
    QPainter p(this);
    if(m_isfront)
    {
        p.drawPixmap(rect(),this->m_front);
    }
    else
    {
        p.drawPixmap(rect(),this->m_back);
    }

}

void CardPanel::mousePressEvent(QMouseEvent *event)
{

}

Player *CardPanel::getOwner() const
{
    return m_owner;
}

void CardPanel::setOwner(Player *owner)
{
    m_owner = owner;
}

bool CardPanel::getIsfront() const
{
    return m_isfront;
}

void CardPanel::setIsfront(bool isfront)
{
    m_isfront = isfront;
}

void CardPanel::setSeclected(bool flag)
{
    this->m_isSelect=flag;
}

bool CardPanel::isSelected()
{
    return this->m_isSelect;
}

void CardPanel::setCard(Card &card)
{
    this->m_card=card;
}

Card CardPanel::getCard()
{
    return this->m_card;
}

